﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Cwjk_PzRuleSet_SelectZy.aspx.vb" Inherits="PubProject.Cwjk_PzRuleSet_SelectZy" %>
<%@ Register TagPrefix="mwc" Namespace="MySoft.WebControls" Assembly="MySoft.WebControls" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head runat="server">
    <title>编辑摘要</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
	<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
	<meta content="JavaScript" name="vs_defaultClientScript">
	<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
	<LINK href="/_nav/menu.css" type="text/css" rel="stylesheet">
	<LINK href="/_common/styles/global.css" type="text/css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="/_common/styles/dialogs.css">
	<LINK href="/_grid/map_grid.css" type="text/css" rel="stylesheet">
	<LINK href="/_forms/styles/form.css" type="text/css" rel="stylesheet">
	<LINK href="/_nav/tabs.css" type="text/css" rel="stylesheet">
	<LINK href="/_nav/nav.css" type="text/css" rel="stylesheet">
	<LINK href="/_common/styles/select.css" type="text/css" rel="stylesheet">
	<script language="javascript" src="/_common/scripts/details.js"></script>
	<script language="javascript" src="/_common/scripts/global.js"></script>
	<script language="javascript" src="/_controls/setting.js"></script>
	<script language="javascript" src="/_controls/util/util.js"></script>
	<script language="javascript" src="/_controls/datetime/date.js"></script>
	<script language="javascript" src="/_controls/datetime/time.js"></script>
	<script language="javascript" src="/_controls/number/number.js"></script>
	<script language="javascript" src="/_controls/lookup/map_lookup.js"></script>
	<script language="javascript" src="/PubProject/Activity/emailtemplateeditor/Scripts/emailtemplateeditor.js"></script>
	<LINK href="/pubproject/_controls/dropdown/dropdown.css" type="text/css" rel="stylesheet">
	<script language="javascript" src="/_forms/FormBase.js"></script>
    <script language="javascript" src="/PubProject/js/public.js"></script>
    <LINK href="/PubProject/Activity/htmlbar/htmlbar.css" type="text/css" rel="stylesheet">
	
	<style>DIV.editPage { BORDER-RIGHT: #808080 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #808080 1px solid; OVERFLOW-Y: auto; PADDING-LEFT: 10px; FONT-SIZE: 10pt; OVERFLOW-X: auto; PADDING-BOTTOM: 10px; BORDER-LEFT: #808080 1px solid; WIDTH: 100%; PADDING-TOP: 10px; BORDER-BOTTOM: #808080 1px solid; FONT-FAMILY: 宋体; HEIGHT: 100%; BACKGROUND-COLOR: #ffffff }
    SPAN.dataslug { BACKGROUND-COLOR: #ffff33 }
    #chkIsPersonal { BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; BORDER-BOTTOM-STYLE: none }
	</style>
	<script language="javascript">
      function GenHtml()
		{	
			TemplateEditorHtml.innerHTML = TemplateEditor.innerHTML;
			
		    if (GetLen(TemplateEditorHtml.innerHTML)> 3012)
			{				    
			    return "Fail";
			}
			
			var o;

			for (i = 0; i < TemplateEditorHtml.all.length; i++)
			{
				o = TemplateEditorHtml.all[i];
				
				if (o.tagName == "SPAN" && o.className == "dataslug")
				{
					if (o.childNodes[0])
					{
						o.swapNode(o.childNodes[0]);
					}
					
					o.removeNode();
					
					i--;
				}
			}

			return TemplateEditorHtml.innerHTML;
		}
		
		//复制粘贴去除格式
        function myPaste()
        {
            var t = window.clipboardData.getData("Text");
            window.clipboardData.setData('text',t);
        }
        function OK()
        {
            var sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx"
            var sDataSource = document.all["txtDataSource"].value;
            sFile += "?DataSource=" + escape(sDataSource) ;
            var strHTML = GenHtml();
            if (strHTML=="Fail")
            {
                alert("内容及其格式合计超过1500个字，请重修调整内容大小或者格式大小！");
                event.returnValue = false;
                return;
            }
            if (getStringLen(strHTML)>2000)
            {
                alert("摘要的长度不可超过2000！");
                event.returnValue = false;
                return;
            }
            
            strReturn = GetDataFromXMLHTTP(sFile,"CWJK_PzGz_PzMx_GetZy","","",strHTML);
            var sZyText,sZySql,sZy;

            if (strReturn!=undefined && strReturn.indexOf("<Sql>")!=-1)
            {
                var iIndex = strReturn.indexOf("<Sql>");
                sZyText = strHTML;
                sZySql = strReturn.substring(iIndex + 5);
                sZySql = sZySql.substring(0,sZySql.length - 6);
                sZy = strReturn.substring(0, iIndex);
                
                if (sZySql.length > 2000 || getStringLen(sZy) > 2000)
                {
                    alert("摘要的长度不可超过2000！");
                    return;
                }                
                if (getStringLen(strHTML) + sZySql.length + getStringLen(sZy) > 8000)
                {
                    alert("数据超长，请重新摘要！");
                    return;
                }
                var arrRtn = {} ;
                arrRtn.Zy = sZy;
                arrRtn.ZySql = sZySql;
                arrRtn.ZyText = sZyText;
                
                parent.window.returnValue = arrRtn;
			    parent.window.close();
            }
            else
            {
                alert("系统超时，请与系统管理员联系！");
                return;
            }
        }
        function getStringLen(sObject)
		{
		    var strlen = sObject.length;
		    
		    for (var i=0; i<sObject.length; i++)
		    {		    
		        if (sObject.charCodeAt(i) > 128)
                {
                    strlen = strlen + 1;
                }
            }
            
            return strlen;
		}
		function window.onload()
		{
		    var oArgs = window.dialogArguments;
		    var sZy = oArgs.Zy;
		    var sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx";
		    var strReturn = GetDataFromXMLHTTP(sFile,"ConvertZyInfo","","",sZy); 
		    if (strReturn!=undefined)
		    {
		        TemplateEditor.innerHTML = strReturn;
		    }
		}
	</script>
</head>
<body style="MARGIN: 15px;>
    <form id="Form1" runat="server">
    <asp:textbox id="txtDataSource" runat="server" style="DISPLAY:none"></asp:textbox>
    <asp:textbox id="txtBizObject" runat="server" style="DISPLAY:none"></asp:textbox>
    <!-- design view start -->
    <table id="viewDesign" style="TABLE-LAYOUT: fixed" height="100%" width="100%" cellSpacing="0" cellPadding="0">
        <tr height="26"  width="100%" >
	        <td><mwc:htmlbar id="crmHtmlBar" runat="server" type="TemplateEditor"></mwc:htmlbar></td>
        </tr>
        <tr  width="100%" valign="top">
	        <td>
		        <div class="editPage" onselectstart="window.event.cancelBubble=true;return true;" oncontrolselect="_oActive = event.srcElement;"
			        id="TemplateEditor" onblur="GenHtml();" onpaste="myPaste();" contentEditable="true" onclick="_oActive = null;"
			        TabIndex="40" onkeydown="if (window.event.keyCode == 46 &amp;&amp; _oActive) _oActive = null;"
			        style="OVERFLOW: auto;width: 100%; HEIGHT: 320px;word-break:break-all"><%= _presentationHtml %></div>
		        <div id="TemplateEditorHtml" style="WIDTH:0px;COLOR:#efefeb;HEIGHT:0px;display:none"></div>
	        </td>
        </tr>
        <TR height="40">
		    <TD class="buttons">
			    <TABLE style="WIDTH: 100%; HEIGHT: 100% " cellSpacing="0" cellPadding="0">
				    <TR>
					    <TD align="right">
						    <BUTTON style="WIDTH: 70px" onclick="OK()" id="btnOK" type="button">确 定</BUTTON>&nbsp;&nbsp;
						    <BUTTON style="WIDTH: 70px" onclick="parent.window.close();" id="btnClose" type="button">关 闭</BUTTON>
					    </TD>
				    </TR>
			    </TABLE>
		    </TD>
		</TR>
		
    </table>
    <!-- design view end -->
    </form>
</body>
</html>
